<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" type="text/css" href="../../resources/estilo.css" />
    <title>Gerenciamento de Funcionarios!</title>
</h:head>

<h:body>
	<ui:include src="menu.xhtml" />
	<div id="table">
	<h:form>
	<h:outputText value="Vagas Restantes: #{turmaManager.sizeTurma()}" />
	
		<p:dataTable value="#{turmaManager.alunosDaTurma}" var="aluno">
			<f:facet name="header">
					<p:outputPanel style="margin-left: 300px;">
							<p:commandButton value="Adicionar Aluno" update="cadaluno"
								oncomplete="dialogGerAluno.show()" />
					</p:outputPanel>
					
				</f:facet>
			<p:column>
				<f:facet name="header">
					<h:outputText value="Aluno"/>
				</f:facet>
				<h:outputText value="#{aluno.nome}" />
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="E-mail"/>
				</f:facet>
				<h:outputText value="#{aluno.email}" />
			</p:column>
			
			<p:column>
					<f:facet name="header">
						<h:outputText value="Alterar" />
					</f:facet>
					<p:commandButton action="#{alunoManager.getDialog(aluno)}"
						value="Alterar" update="cadaluno"
						oncomplete="#{alunoManager.getDialog(aluno)}" />
			</p:column>
		</p:dataTable>
	</h:form>
	</div>
	
	<p:dialog header="Notas" widgetVar="dialogGerAluno"
		width="500" height="560" resizable="false" showEffect="slide">
		<h:form id="cadaluno">
			<h:panelGrid columns="2" cellpadding="5">
				<h:outputText value="nome: " />
				<p:inputText value="#{alunoManager.aluno.nome}"/>
				<h:outputText value="Sobrenome: " />
				<p:inputText value="#{alunoManager.aluno.sobrenome}"/>
				<h:outputText value="Data Nascimento: " />
				<p:inputText value="#{alunoManager.aluno.dtNascimento}"/>
				
				<h:outputText value="E-mail: " />
				<p:inputText value="#{alunoManager.aluno.email}"/>
				
				<h:outputText value="login: " />
				<p:inputText value="#{alunoManager.aluno.login}"/>
				
				<h:outputText value="senha: " />
				<p:inputText value="#{alunoManager.aluno.senha}"/>
				
				<h:outputText value="Sexo: "/>
				<h:selectOneRadio value="#{alunoManager.aluno.sexo}">
					<f:selectItem itemValue="M" itemLabel="Masculino"/>
					<f:selectItem itemValue="F" itemLabel="Feminino" />
				</h:selectOneRadio>
				
								
				<h:outputText value="Turma: " />
				<h:selectOneMenu value="#{alunoManager.turmaId}">
					<f:selectItem itemLabel="Selecione a turma" itemValue="null" />
					<f:selectItems value="#{turmaManager.turmas}" var="turma"
						itemLabel="#{turma.curso.nome} - #{turma.id}" itemValue="#{turma.id}" />
				</h:selectOneMenu>
				
				<h:outputText value="CPF: " />
				<p:inputText value="#{alunoManager.aluno.cpf}" mask="999.999.999-99"/>
				
				<h:outputText value="Estado: " />
				<h:selectOneMenu value="#{alunoManager.endereco.estado}">
					<f:selectItem itemLabel="Selecione o estado" itemValue="null"/>
					<f:selectItem itemLabel="CE" itemValue="ce" />
					<f:selectItem itemLabel="PE" itemValue="pe" />
					<f:selectItem itemLabel="RN" itemValue="rn" />
				</h:selectOneMenu>
				
				<h:outputText value="senha: " />
				<p:inputText value="#{alunoManager.endereco.cidade}"/>
				
				<h:outputText value="Bairro: " />
				<p:inputText value="#{alunoManager.endereco.bairro}"/>
				
				<h:outputText value="Logradouro: " />
				<p:inputText value="#{alunoManager.endereco.logradouro}"/>
				
				<h:outputText value="Numero: " />
				<p:inputText value="#{alunoManager.endereco.numero}"/>
				
				<h:outputText value="Complemento: " />
				<p:inputText value="#{alunoManager.endereco.complemento}"/>
				
				<h:outputText value="Bairro: " />
				<p:inputText value="#{alunoManager.telefone.telefone}"/>
				
				<h:inputHidden value="#{alunoManager.aluno.id}"/>
				
				<p:commandButton value="Salvar" action="#{alunoManager.save()}" ajax="false"/>
			</h:panelGrid>
				
		</h:form>
	</p:dialog>
</h:body>
</html>